package com.trailwalker.traceability.entitiy.enum_entity;

/**
 * @author Trailwalker
 * @create 2021-11-12 10:29
 */
public enum ProcessType {
    /**
     * 半成品测试
     */
    SEMI_FINISHED_PRODUCT_TEST("半成品测试", 0),

    /**
     * 单板测试
     */
    SINGLE_BOARD_TEST("单板测试", 1),

    /**
     * 点胶站测试
     */
    DISPENSING_STATION_TEST("点胶站测试", 2),

    /**
     * 成品测试
     */
    FINISHED_PRODUCT_TEST("成品测试", 3),

    /**
     * 实验室
     */
    LABORATORY("实验室", 4),

    /**
     * 终检
     */
    FINAL_INSPECTION("终检", 5),

    /**
     * 包装
     */
    PACKAGING("包装", 6),

    /**
     * 入库
     */
    PUT_IN_STORAGE("入库", 7),

    /**
     * 出库
     */
    OUTBOUND("出库", 8),

    /**
     * 未知
     */
    UNKNOWN("未知", -1);

    private String name;
    private int index;

    ProcessType(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public static ProcessType getProcessTypeByName(String name) {
        ProcessType[] processTypes = ProcessType.values();
        for (int i = 0; i < processTypes.length; i++) {
            ProcessType processType = processTypes[i];
            if (processType.getName().equals(name)) {
                return processType;
            }
        }
        return UNKNOWN;
    }

    public static ProcessType getProcessTypeByIndex(int index) {
        ProcessType[] processTypes = ProcessType.values();
        for (int i = 0; i < processTypes.length; i++) {
            ProcessType processType = processTypes[i];
            if (processType.getIndex() == index) {
                return processType;
            }
        }
        return UNKNOWN;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
